package com.anxin.registerManagement.util;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 统一返回结果
 */
@Data
@ApiModel("统一返回结果")
public class ResultUtil {

    @ApiModelProperty("返回状态码")
    private int code;

    @ApiModelProperty("返回信息")
    private String message;

    @ApiModelProperty("返回数据")
    private Object data;


    public static ResultUtil success() {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(Const.SUCCESS_CODE);
        resultUtil.setMessage(Const.SUCCESS_MESSAGE);
        return resultUtil;
    }

    public static ResultUtil success(Object data) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(Const.SUCCESS_CODE);
        resultUtil.setMessage(Const.SUCCESS_MESSAGE);
        resultUtil.setData(data);
        return resultUtil;
    }

    public static ResultUtil success(String message, Object data) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(Const.SUCCESS_CODE);
        resultUtil.setMessage(message);
        resultUtil.setData(data);
        return resultUtil;
    }

    public static ResultUtil fail() {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(Const.FAIL_CODE);
        resultUtil.setMessage(Const.FAIL_MESSAGE);
        return resultUtil;
    }


    public static ResultUtil fail(String message) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(Const.FAIL_CODE);
        resultUtil.setMessage(message);
        return resultUtil;
    }

    public static ResultUtil fail(int code, String message) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(code);
        resultUtil.setMessage(message);
        return resultUtil;
    }


    public static ResultUtil fail(int code, String message, Object data) {
        ResultUtil resultUtil = new ResultUtil();
        resultUtil.setCode(code);
        resultUtil.setMessage(message);
        resultUtil.setData(data);
        return resultUtil;
    }
}
